<!--
*  功能描述：绩效管理：项目人员进度
 -->
 <template>
  <div>
    <div>
      <el-descriptions title="项目人员进度" :column="2" border>
      </el-descriptions>
      <el-form :inline="true" class="demo-form-inline">
        <el-form-item label="考核任务:">
          <el-select v-model="id" placeholder="请选择">
            <el-option v-for="item in options" :key="item.AssId" :label="item.AssId" :value="item.AssId">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">查询</el-button>
          <el-button type="danger" @click="PUPdate">批量发起</el-button>
        </el-form-item>
      </el-form>
    </div>
    <el-table ref="multipleTable" :data="tableData" tooltip-effect="dark" style="width: 100%"
      @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55">
      </el-table-column>
      <el-table-column prop="PrName" label="考核名称">
      </el-table-column>
      <el-table-column label="考核人员">
        <template slot-scope="scope">
          <el-button type="primary" @click="showft(scope.row.ProId)">查看</el-button>
        </template>
      </el-table-column>
      <el-table-column prop="ProHost" label="主持人">
        <template slot-scope="scope">
          <el-button type="success" icon="el-icon-check" circle v-if="scope.row.ProHost"></el-button>
          <el-button type="danger" icon="el-icon-close" circle v-else></el-button>
        </template>
      </el-table-column>
      <el-table-column prop="ProDivision1" label="部门经理">
        <template slot-scope="scope">
          <el-button type="success" icon="el-icon-check" circle v-if="scope.row.ProDivision1"></el-button>
          <el-button type="danger" icon="el-icon-close" circle v-else></el-button>
        </template>
      </el-table-column>
      <el-table-column prop="ProConstruction" label="建筑负责人">
        <template slot-scope="scope">
          <el-button type="success" icon="el-icon-check" circle v-if="scope.row.ProConstruction"></el-button>
          <el-button type="danger" icon="el-icon-close" circle v-else></el-button>
        </template>
      </el-table-column>
      <el-table-column prop="ProDivision2" label="部门经理">
        <template slot-scope="scope">
          <el-button type="success" icon="el-icon-check" circle v-if="scope.row.ProDivision2"></el-button>
          <el-button type="danger" icon="el-icon-close" circle v-else></el-button>
        </template>
      </el-table-column>
      <el-table-column prop="ProStructure" label="结构负责人">
        <template slot-scope="scope">
          <el-button type="success" icon="el-icon-check" circle v-if="scope.row.ProStructure"></el-button>
          <el-button type="danger" icon="el-icon-close" circle v-else></el-button>
        </template>
      </el-table-column>
      <el-table-column prop="ProDivision3" label="部门经理">
        <template slot-scope="scope">
          <el-button type="success" icon="el-icon-check" circle v-if="scope.row.ProDivision3"></el-button>
          <el-button type="danger" icon="el-icon-close" circle v-else></el-button>
        </template>
      </el-table-column>
      <el-table-column prop="ProHvac" label="暖通负责人">
        <template slot-scope="scope">
          <el-button type="success" icon="el-icon-check" circle v-if="scope.row.ProHvac"></el-button>
          <el-button type="danger" icon="el-icon-close" circle v-else></el-button>
        </template>
      </el-table-column>
      <el-table-column prop="ProDivision4" label="部门经理">
        <template slot-scope="scope">
          <el-button type="success" icon="el-icon-check" circle v-if="scope.row.ProDivision4"></el-button>
          <el-button type="danger" icon="el-icon-close" circle v-else></el-button>
        </template>
      </el-table-column>
      <el-table-column prop="ProDrainage" label="给排水负责人">
        <template slot-scope="scope">
          <el-button type="success" icon="el-icon-check" circle v-if="scope.row.ProDrainage"></el-button>
          <el-button type="danger" icon="el-icon-close" circle v-else></el-button>
        </template>
      </el-table-column>
      <el-table-column prop="ProDivision5" label="部门经理">
        <template slot-scope="scope">
          <el-button type="success" icon="el-icon-check" circle v-if="scope.row.ProDivision5"></el-button>
          <el-button type="danger" icon="el-icon-close" circle v-else></el-button>
        </template>
      </el-table-column>
      <el-table-column prop="ProAppliance" label="电气负责人">
        <template slot-scope="scope">
          <el-button type="success" icon="el-icon-check" circle v-if="scope.row.ProAppliance"></el-button>
          <el-button type="danger" icon="el-icon-close" circle v-else></el-button>
        </template>
      </el-table-column>
      <el-table-column prop="ProDivision6" label="部门经理">
        <template slot-scope="scope">
          <el-button type="success" icon="el-icon-check" circle v-if="scope.row.ProDivision6"></el-button>
          <el-button type="danger" icon="el-icon-close" circle v-else></el-button>
        </template>
      </el-table-column>
      <el-table-column prop="ProStart" label="考核状态">
        <template slot-scope="scope">
          <el-button type="warning" @click="faqi(scope.row.ProId)" v-if="scope.row.ProStart">发起审批</el-button>
          <el-button type="warning" @click="faqi" v-else disabled>发起审批</el-button>
        </template>

      </el-table-column>
      <el-table-column>
      </el-table-column>
    </el-table>
    <div class="block">
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="pageIndex"
        :page-sizes="[1, 3, 7, 14]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper"
        :total="totalCount">
      </el-pagination>
    </div>
    <div>
      <el-dialog title="收货地址" :visible.sync="dialogTableVisible">
        <el-table :data="gridData" style="width: 100%">
          <el-table-column prop="ProHost" label="主持人">
          </el-table-column>
          <el-table-column prop="ProConstruction" label="建筑负责人">
          </el-table-column>
          <el-table-column prop="ProStructure" label="结构负责人">
          </el-table-column>
          <el-table-column prop="ProHVAC" label="暖通负责人">
          </el-table-column>
          <el-table-column prop="ProDrainage" label="给排水负责人">
          </el-table-column>
          <el-table-column prop="ProAppliance" label="电器负责人">
          </el-table-column>
        </el-table>
      </el-dialog>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      tableData: [],
      options: [],
      gridData: {
      },
      id: '',
      totalCount: 50,
      pageIndex: 1,
      pageSize: 7,
      dialogTableVisible: false,
      multipleSelection: [],
    }
  },
  methods: {
    show () {
      this.$http({
        url: 'AssProgres/GetViewPrjectLists',
        method: 'get',
        params: {
          id: this.id,
          pageIndex: this.pageIndex,
          pageSize: this.pageSize
        }
      })
        .then(res => {
          this.tableData = res.data.list
          this.totalCount = res.data.totalCount
        })
    },
    showft (ids) {
      this.dialogTableVisible = true;
      this.$http({
        url: 'AssProgres/GetAssProgressFT',
        method: 'get',
        params: {
          id: ids,
        }
      })
        .then(res => {
          this.gridData = res.data
          console.log(res.data)
        })

    },
    onSubmit () {
      this.show();
    },
    showMent () {//任务下拉
      this.$http({
        url: 'AssProjectA/GetAssessmentList',
        method: 'get',
      })
        .then(res => {
          this.options = res.data
        })
    },
    handleSizeChange (val) {
      this.pageSize = val;
      this.show();
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange (val) {
      this.pageIndex = val;
      this.show();
      console.log(`当前页: ${val}`);
    },
    faqi (id) {//发起审批
      this.$http({
        url: 'AssProgres/PutAssProgress',
        method: 'put',
        params: {
          id: id
        }
      })
        .then(res => {
          if (res.data > 0) {
            alert('部门经理或负责人没有设置完成，不能发起审批')
            this.show();
            return;
          }

        })

    },
    handleSelectionChange (val) {
      this.multipleSelection = val;
    },
    PUPdate () {//批量发起
      var ids = [];
      for (var i = 0; i < this.multipleSelection.length; i++) {
        ids.push(this.multipleSelection[i].ProId)
      }
      if (ids.toString() == "") {

        alert('至少选择一条');
        return;
      }
      this.$http({
        url: 'AssProgres/PutAssProgress1',
        method: 'put',
        params: {
          ids: ids.toString()
        }
      })
        .then(res => {
          if (res.data > 0) {
            alert('批量发起成功');
            this.show();
          }
        })
    }

  },
  mounted () {
    this.show();
    this.showMent();
  }
}
</script>